<!DOCTYPE html>
<!--引入-->
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
<!--声明对象-->
<script type="text/javascript">
    window.onload = function () {
    var app = new Vue({
        el: '#app',
        data: {
            message: 'Hello Vue!',
            isok: true,
            test_list: ['a', 'b', 'c', 'd'] // 数组
        },
        methods: {
           btnBeClicked:function(){
                alert('haha')
            }
        },
        computed: {
            new_msg: function () {
                return this.message + '!@'  //func前不允许用this
            }
        },
        watch: {
           new_msg: function (new_msg, old_msg) {
                console.log(new_msg)
                console.log(old_msg)
           }
        }
    })
}
</script>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="app">
        <div v-if="isok">第一个div</div>
        <br>
        <div v-show="isok">第二个div</div>
        <ul>
            <li v-for="item in test_list">
                <p>{{item}}</p>
            </li>
        </ul>
        <br>

        <p>{{message}}</p>
        <p>{{new_msg}}</p>
        <button v-on:click="btnBeClicked">按钮</button>
<!--        <input v-model="message">-->
    </div>
    <div v-bind:class="{isActive ? 'box': '', 'divbox'}"> test </div>
</body>
</html>